// nef_demo.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"
#include "catalog.h"
#include "Contracts.h"
#include "Manipulator.h"
#include "nef_register.h"
#include <iostream>

using namespace std;

// Allow components to register in this module.
// This macro MUST be defined somewhere in any module that wants to export any parts.
// The best place to put it is in dllmain.cpp
NEF_ENTRY_POINT()

int _tmain(int argc, _TCHAR* argv[])
{
	auto cat = nef::Catalog::Create();
	
	// Load all of the components in the same execution directory
	cat->LoadFolder(".\\");
	
	try
	{
		auto manip = cat->GetExportedValue<ComponentManipulator>();

		cout << "No Contract:" << endl << endl;
		auto strs = manip->CallAllOperations("Hello", "World");

		cout << endl << endl << "Outputs:" << endl;
		for (auto s : strs)
			cout << s << endl;

		cout << endl << endl << "10 Separators: " << endl;

		// This example shows how we can get a factory for the export, so that we can control the creation of the specific type
		auto sepFact = cat->GetExportFactory<ISeparator>("Exotic");
		for (int i = 0; i < 10; i++)
			cout << sepFact->create()->GetSeparator() << endl;
	}
	catch (nef::export_exception &ex)
	{
		cout << "Error:" << endl << ex.what();
	}

	getchar();

	return 0;
}

